package homeword;

import java.util.Random;

public class 评委打分 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] scores = new int[6];
        for (int f = 1; f < 7; f++) {
            int score = random.nextInt(99);
            System.out.println(f + "号评委给的分数是" + score);
            scores[f - 1] = score;
        }
        int max = Max(scores);
        int min = Min(scores);
        int smu = 0;
        System.out.println("去除最大值" + max + "和最小值" + min);
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] == max) {
                continue;
            }
            if (scores[i] == min) {
                continue;
            }
            smu += scores[i];
        }
        int result = smu / scores.length - 2;
        System.out.println("最终评分是" + result);
    }

    public static int Max(int[] scores) {
        int max = scores[0];
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] > max) {
                max = scores[i];
            }
        }
        return max;
    }

    public static int Min(int[] scores) {
        int min = scores[0];
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] < min) {
                min = scores[i];
            }
        }
        return min;

    }
}
